package it.carlom.stikkyheader.core;

import ohos.agp.components.Component;

public class StikkyCompat {

    interface StikkyCompatImpl {
        float getTranslationX(Component view);

        float getTranslationY(Component view);

        void setTranslationX(Component view, float value);

        void setTranslationY(Component view, float value);

        void setScaleX(Component view, float value);

        void setScaleY(Component view, float value);

        float getScaleX(Component view);

        float getScaleY(Component view);

        void setAlpha(Component view, float value);

        float getAlpha(Component view);
    }

    private static final StikkyCompatImpl IMPL;

    static {
            IMPL = new HCImpl();
    }

    public static float getTranslationX(Component view) {
        return IMPL.getTranslationX(view);
    }

    public static float getTranslationY(Component view) {
        return IMPL.getTranslationY(view);
    }

    public static void setTranslationX(Component view, float value) {
        IMPL.setTranslationX(view, value);
    }

    public static void setTranslationY(Component view, float value) {
        IMPL.setTranslationY(view, value);
    }

    public static void setScaleX(Component view, float value) {
        IMPL.setScaleX(view, value);
    }

    public static void setScaleY(Component view, float value) {
        IMPL.setScaleY(view, value);
    }

    public static void setAlpha(Component view, float value) {
        IMPL.setAlpha(view, value);
    }

    public static float getScaleX(Component view) {
        return IMPL.getScaleX(view);
    }

    public static float getScaleY(Component view) {
        return IMPL.getScaleY(view);
    }

    public static float getAlpha(Component view) {
        return IMPL.getAlpha(view);
    }

    private static class HCImpl implements StikkyCompatImpl {

        @Override
        public float getTranslationX(Component view) {
            return view.getTranslationX();
        }

        @Override
        public float getTranslationY(Component view) {
            return view.getTranslationY();
        }

        @Override
        public void setTranslationX(Component view, float value) {
            view.setTranslationX(value);
        }

        @Override
        public void setTranslationY(Component view, float value) {
            view.setTranslationY(value);
        }

        @Override
        public void setScaleX(Component view, float value) {
            view.setScaleX(value);
        }

        @Override
        public void setScaleY(Component view, float value) {
            view.setScaleY(value);
        }

        @Override
        public float getScaleX(Component view) {
            return view.getScaleX();
        }

        @Override
        public float getScaleY(Component view) {
            return view.getScaleY();
        }

        @Override
        public void setAlpha(Component view, float value) {
            view.setAlpha(value);
        }

        @Override
        public float getAlpha(Component view) {
            return view.getAlpha();
        }
    }

}
